package cn.tedu.ivos.user.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.user.service.UserService;
import cn.tedu.ivos.user.pojo.dto.UserLoginParam;
import cn.tedu.ivos.user.pojo.vo.UserVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/user")
@Tag(name = "用户模块")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/login")
    @Operation(summary = "用户登录")
    public JsonResult login(@RequestBody @Validated UserLoginParam  userLoginParam) {
        log.debug("开始处理用户登录的请求，参数：{}", userLoginParam);
        UserVO userVO =userService.login(userLoginParam);
        return JsonResult.ok(userVO);
    }
    @GetMapping("/list")
    @Operation(summary = "用户列表")
    public JsonResult userList(){
        log.debug("开始处理用户列表的请求");
        List<UserVO> list = userService.list();
        return JsonResult.ok(list);
    }

}
